#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2019/4/9  20:44
# @Author: 余浪人
# @email: yulangren520@gmail.com

import datetime
import os

def get_sys_uri():
    base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))).replace('\\', '/')
    return base_dir



def Mysql(user, password, dbName, location='localhost', post=3306):
    return f"mysql+cymysql://{user}:{password}@{location}:{post}/{dbName}"


# ********************************************** 配置信息**********************************************#
class Config:
    SQLALCHEMY_DATABASE_URI = 'sqlite:///{}/tl_cms_db.db'.format(get_sys_uri())  # sqlite 数据库
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    SESSION_KEY_PREFIX = "TL_CMS"
    PERMANENT_SESSION_LIFETIME = datetime.timedelta(seconds=12 * (60 * 60))
    SECRET_KEY = '*!-TL-&*1'
    EXPIRATION = 25200
    ALIPAY_URL = 'https://openapi.alipaydev.com/gateway.do'
    PAGE_INTERVAL = 15
    PAST_TIME = 3600 * 24
    CACHE_TYPE = 'simple'
    CACHE_DEFAULT_TIMEOUT=2*((60*60)*24)
    CACHE_THRESHOLD=1000
    VERIFY_CODE_TIME = 2
    APP_ID = 101798980
    REDIRECT_URI = "http://specimen.vip/auto_login"
    UPLOAD_PATH='/upload'
    HOST = 'http://www.tlcms.net'
    PORT = 5000
    RESTRICT_TIME = 60
    MAX_NUM = 60


class SchedulerConfig:
    JOBS = []

class ProductionConfig(Config,SchedulerConfig):
    # ******* 配置数据库 *******#
    pass
    # SQLALCHEMY_DATABASE_URI = Mysql('demo_pay_tlcms_n', 'yLewHLpdRWc6Ctym', 'demo_pay_tlcms_n','39.106.227.4',3306)  # Mysql 数据库
